package org.jeecg.modules.wms.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.wms.entity.FinishedGoodsInventory;
import org.jeecg.modules.wms.vo.InventoryAdjustVO;
import org.jeecg.modules.wms.vo.InventoryQueryParam;
import org.jeecg.modules.wms.vo.CustomerInventoryGroup;
import org.jeecg.modules.wms.vo.HierarchicalInventoryQueryParam;
import org.jeecg.modules.wms.vo.InventoryStatisticsVO;

import java.util.List;

/**
 * 成品库存管理Service接口
 */
public interface IFinishedGoodsInventoryService extends IService<FinishedGoodsInventory> {

    /**
     * 分页查询成品库存列表
     */
    IPage<FinishedGoodsInventory> queryInventoryList(IPage<FinishedGoodsInventory> page, InventoryQueryParam param);

    /**
     * 按订单查询库存分布
     */
    List<FinishedGoodsInventory> queryInventoryByOrder(String orderNo);

    /**
     * 库存调整
     */
    void adjustInventory(InventoryAdjustVO adjustVO);

    /**
     * 按仓库统计库存
     */
    List<InventoryStatisticsVO> statisticsByWarehouse();

    /**
     * 按订单统计库存
     */
    List<InventoryStatisticsVO> statisticsByOrder();

    /**
     * 按门窗系列统计库存
     */
    List<InventoryStatisticsVO> statisticsByWindowSeries();

    /**
     * 获取库存总览统计
     */
    InventoryStatisticsVO getInventoryOverview();

    /**
     * 查询低库存预警
     */
    List<FinishedGoodsInventory> queryLowStockWarning(Integer threshold);

    /**
     * 预留库存
     */
    boolean reserveInventory(String inventoryId, Integer quantity, String reason);

    /**
     * 释放预留库存
     */
    boolean releaseReservedInventory(String inventoryId, Integer quantity, String reason);

    /**
     * 扣减库存（出库时使用）
     */
    boolean deductInventory(String inventoryId, Integer quantity, String relatedDocNo);

    /**
     * 增加库存（入库时使用）
     */
    boolean addInventory(String inventoryId, Integer quantity, String relatedDocNo);

    /**
     * 移动端查询成品库存
     */
    IPage<FinishedGoodsInventory> queryInventoryForMobile(IPage<FinishedGoodsInventory> page, InventoryQueryParam param);

    /**
     * 移动端分层查询成品库存（按客户-订单分组）
     */
    List<CustomerInventoryGroup> queryHierarchicalInventoryForMobile(HierarchicalInventoryQueryParam param);

    /**
     * Web端分层查询成品库存（按客户-订单分组，支持分页）
     */
    IPage<CustomerInventoryGroup> queryHierarchicalInventoryForWeb(IPage<CustomerInventoryGroup> page, HierarchicalInventoryQueryParam param);

    List<FinishedGoodsInventory> queryByOrderDetailId(String orderDetailId);

    /**
     * 获取成品入库单总数
     * @return 成品入库单总数
     */
    Long getFinishedGoodsInboundOrderCount();

    /**
     * 获取成品出库单总数
     * @return 成品出库单总数
     */
    Long getFinishedGoodsOutboundOrderCount();
}
